import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  {
    path: '/personnelFilesDialog/:id',
    name: 'personnelFilesDialog',
    component: () => import('@/views/personnelFilesDialog/index'),
    meta: { title: '人员档案弹窗', icon: 'table' }
  },
  {
    path: '/personnelFilesPrint/:id',
    name: 'personnelFilesPrint',
    component: () => import('@/views/personnelFilesPrint/index'),
    meta: { title: '人员打印弹窗', icon: 'table' }
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home/index',
    name: 'home',
    hidden: true,
    children: [
      {
        path: 'index',
        name: 'Home',
        component: () => import('@/views/home/index'),
        meta: { title: '首页', icon: 'form' }
      }
    ]
  },
  {
    path: '/home',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Home',
        component: () => import('@/views/home/index'),
        meta: { title: '首页', icon: 'form' }
      }
    ]
  },
  {
    path: '/departPersonManage',
    component: Layout,
    redirect: '/departPersonManage/departManagement',
    name: 'departPersonManage',
    meta: { title: '部门人员管理', icon: 'example' },
    children: [
      {
        path: 'departManagement',
        name: 'departManagement',
        component: () => import('@/views/departManagement/index'),
        meta: { title: '部门管理', icon: 'table' }
      },
      {
        path: 'personnelFiles',
        name: 'personnelFiles',
        component: () => import('@/views/personnelFiles/index'),
        meta: { title: '人员档案', icon: 'table' }
      },
      // {
      //   path: 'workLog',
      //   name: 'workLog',
      //   component: () => import('@/views/workLog/index'),
      //   meta: { title: '工作日志', icon: 'table' }
      // },
    ]
  },
  // {
  //   path: '/systemSetup',
  //   component: Layout,
  //   redirect: '/systemSetup/appVersion',
  //   name: 'systemSetup',
  //   meta: { title: '系统管理', icon: 'example' },
  //   children: [
  //     {
  //       path: 'appVersion',
  //       name: 'appVersion',
  //       component: () => import('@/views/appVersion/index'),
  //       meta: { title: 'APP版本', icon: 'table' }
  //     }
  //   ]
  // },
  {
    path: '/accountManagement',
    component: Layout,
    redirect: '/accountManagement/roleManagement',
    name: 'systemSetup',
    meta: { title: '账号管理', icon: 'example' },
    children: [
      {
        path: 'roleManagement',
        name: 'roleManagement',
        component: () => import('@/views/roleManagement/index'),
        meta: { title: '人员账号角色管理', icon: 'table' }
      },
      {
        path: 'personManagement',
        name: 'personManagement',
        component: () => import('@/views/personManagement/index'),
        meta: { title: '人员账号管理', icon: 'table' }
      },
    ]
  },
  { path: '*', redirect: '/home/index', hidden: true }
]

export default new Router({
  base: 'web_oa',
  mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

